import java.util.HashSet;
import java.util.Set;

/**
 * @ClassName LC217 217. 存在重复元素
 * @Author ykx
 * @Date 2024/6/23 16:01
 * @Version 1.0
 */
public class LC217 {
    public static void main(String[] args) {
        LC217 lc217 = new LC217();
        System.out.println(lc217.containsDuplicate(new int[]{1, 2, 3, 4}));
    }

    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            if (!set.add(num)) {
                return true;
            }
        }
        return false;
    }

}
